package com.winai.launcher.utils;

import com.ks.projectbasictools.retrofit.HttpResponseListener;
import com.ks.projectbasictools.retrofit.Request;
import com.ks.projectbasictools.retrofit.ServerHttp;

import java.util.HashMap;
import java.util.Map;

public class ServerUtils extends com.ks.projectbasictools.retrofit.ServerUtils {

    public static <T> void requestJsonPost(String url, Map<String, Object> paramMap, Object requestObj, HttpResponseListener<T> listener) {
        Map<String, Object> map = new HashMap<>();
        map.put("content-type", "application/json");
        Request request = ServerHttp.newPostRequest(url);
        request.putHeaderMap(map);
        if (paramMap != null) {
            request.putParamsMap(paramMap);
        }
        ServerHttp.sendJson(request, requestObj, listener);
    }

    public static <T> void requestJsonGet(String url, Map<String, Object> paramMap, Object requestObj, HttpResponseListener<T> listener) {
        Map<String, Object> map = new HashMap<>();
        map.put("content-type", "application/json");
        Request request = ServerHttp.newGetRequest(url);
        request.putHeaderMap(map);
        if (paramMap != null) {
            request.putParamsMap(paramMap);
        }
        ServerHttp.sendJson(request, requestObj, listener);
    }
}
